/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package homework6;

/**
 *
 * @author Administrator
 */
import java.util.*;
public class MainG{
    public static void main(String []args){
        Scanner reader = new Scanner(System.in);
        String start,end;
        int h1,h2,m1,m2,time;
        start = reader.next();
        end = reader.next();
        h1 = Integer.parseInt(start.substring(0, 2));
        h2 = Integer.parseInt(end.substring(0, 2));
        m1 = Integer.parseInt(start.substring(3, 5));
        m2 = Integer.parseInt(end.substring(3, 5));
        time = (h2-h1)*60 + (m2-m1);
        System.out.println(time);
    }
}
